import * as calculateService from '../../services/design/calculate';
import { notification } from 'antd';
export default {
    namespace: 'calculate',
    state: {
       
    },
    reducers: {
       
    },
    effects: {
        *freePoint({ payload: { values, onSuccess, onError } }, { call, put, select }) {
            const res = yield call(calculateService.freePoint, values);
            if (res && res.data && res.data.code == "200") {
                notification.info({ message: "任意点计算成功" });
                onSuccess(res);
            } else {
                onError(res && res.data ? res.data.message : '服务器连接失败');
            }
        },
        *freeElevation({ payload: { values, onSuccess, onError } }, { call, put, select }) {
            const res = yield call(calculateService.freeElevation, values);
            if (res && res.data && res.data.code == "200") {
                notification.info({ message: "任意高程计算成功" });
                onSuccess(res);
            } else {
                onError(res && res.data ? res.data.message : '服务器连接失败');
            }
        },
        *addSteelStructure({ payload: { values, onSuccess, onError } }, { call, put, select }) {
            const res = yield call(calculateService.addSteelStructure, values);
            if (res && res.data && res.data.code == "200") {
                notification.info({ message: "连续钢构添加成功" });
                onSuccess(res);
            } else {
                onError(res && res.data ? res.data.message : '服务器连接失败');
            }
        },
        *beamConstructionTree({ payload: values }, { call, put, select }) {
            const res = yield call(calculateService.beamConstructionTree, { ...values });
            if (res && res.data && res.data.code == "200") {
            } else {

            }
            return res && res.data && res.data.data ? res.data.data : null
        },
        *cushionPoint({ payload: { values, onSuccess, onError } }, { call, put, select }) {
            const res = yield call(calculateService.cushionPoint, values);
            if (res && res.data && res.data.code == "200") {
                notification.info({ message: "垫石高程计算成功" });
                onSuccess(res);
            } else {
                onError(res && res.data ? res.data.message : '服务器连接失败');
            }
        },
        *calculateBeam({ payload: { values, onSuccess, onError } }, { call, put, select }) {
            const res = yield call(calculateService.calculateBeam, values);
            if (res && res.data && res.data.code == "200") {
                notification.info({ message: "预制梁长计算成功" });
                onSuccess(res);
            } else {
                onError(res && res.data ? res.data.message : '服务器连接失败');
            }
        },
       
    }
}